package org.jeecg.modules.online.config.service.p023a;

import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.online.cgform.consts.ExtendJsonKey;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.config.p022d.ColumnMeta;
import org.jeecg.modules.online.config.p022d.DataBaseConst;
import org.jeecg.modules.online.config.service.DbTableHandleI;

/* renamed from: org.jeecg.modules.online.config.service.a.b */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/config/service/a/b.class */
public class DbTableDmHandleImpl implements DbTableHandleI {
    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getAddColumnSql(ColumnMeta columnMeta) {
        return " ADD COLUMN " + m19a(columnMeta) + "";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getReNameFieldName(ColumnMeta columnMeta) {
        return "RENAME COLUMN " + columnMeta.getOldColumnName() + " TO " + columnMeta.getColumnName() + "";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getUpdateColumnSql(ColumnMeta cgformcolumnMeta, ColumnMeta datacolumnMeta) {
        return " MODIFY " + m18a(cgformcolumnMeta, datacolumnMeta) + "";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getMatchClassTypeByDataType(String dataType, int digits) {
        String str = "";
        if ("varchar2".equalsIgnoreCase(dataType)) {
            str = "string";
        } else if (DataBaseConst.f581l.equalsIgnoreCase(dataType)) {
            str = "string";
        } else if ("nvarchar2".equalsIgnoreCase(dataType)) {
            str = "string";
        } else if ("double".equalsIgnoreCase(dataType)) {
            str = "double";
        } else if (DataBaseConst.f577h.equalsIgnoreCase(dataType) && digits == 0) {
            str = "int";
        } else if (DataBaseConst.f577h.equalsIgnoreCase(dataType) && digits != 0) {
            str = "double";
        } else if ("int".equalsIgnoreCase(dataType)) {
            str = "int";
        } else if ("Date".equalsIgnoreCase(dataType)) {
            str = "date";
        } else if ("timestamp".equalsIgnoreCase(dataType)) {
            str = "datetime";
        } else if ("datetime".equalsIgnoreCase(dataType)) {
            str = "datetime";
        } else if ("blob".equalsIgnoreCase(dataType)) {
            str = "blob";
        } else if ("clob".equalsIgnoreCase(dataType)) {
            str = ExtendJsonKey.f133f;
        }
        return str;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String dropTableSQL(String tableName) {
        return " DROP TABLE IF EXISTS " + tableName.toLowerCase() + " ";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getDropColumnSql(String fieldName) {
        return " DROP COLUMN " + fieldName.toUpperCase() + "";
    }

    /* renamed from: a */
    private String m19a(ColumnMeta columnMeta) {
        String str = "(\"" + columnMeta.getColumnName() + "\"";
        if ("string".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " varchar2(" + columnMeta.getColumnSize() + ")";
        } else if ("date".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " date";
        } else if ("datetime".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " datetime";
        } else if ("int".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " INT";
        } else if ("double".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " NUMBER(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ")";
        } else if ("bigdecimal".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " DECIMAL(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ")";
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " CLOB ";
        } else if ("blob".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = str + " BLOB ";
        }
        return ((str + (StringUtils.isNotEmpty(columnMeta.getFieldDefault()) ? " DEFAULT " + columnMeta.getFieldDefault() : " ")) + ("Y".equals(columnMeta.getIsNullable()) ? " NULL" : " NOT NULL")) + ")";
    }

    /* renamed from: a */
    private String m18a(ColumnMeta columnMeta, ColumnMeta columnMeta2) {
        String str = "";
        String str2 = "";
        if (!columnMeta2.getIsNullable().equals(columnMeta.getIsNullable())) {
            str2 = "Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL";
        }
        if ("string".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " varchar2(" + columnMeta.getColumnSize() + ")";
        } else if ("date".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " date ";
        } else if ("datetime".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime ";
        } else if ("int".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " INT ";
        } else if ("double".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " NUMBER(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ") ";
        } else if ("bigdecimal".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " DECIMAL(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ") ";
        } else if ("blob".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " BLOB ";
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " CLOB ";
        }
        return (str + (StringUtils.isNotEmpty(columnMeta.getFieldDefault()) ? " DEFAULT " + columnMeta.getFieldDefault() : " ")) + str2;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getCommentSql(ColumnMeta columnMeta) {
        return "COMMENT ON COLUMN " + columnMeta.getTableName() + "." + columnMeta.getColumnName() + " IS '" + columnMeta.getComment() + CgformUtil.f231C;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getSpecialHandle(ColumnMeta cgformcolumnMeta, ColumnMeta datacolumnMeta) {
        return null;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String dropIndexs(String indexName, String tableName) {
        return "DROP INDEX " + indexName;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String countIndex(String indexName, String tableName) {
        return "select count(*) from user_ind_columns where index_name=upper('" + indexName + "')";
    }
}
